﻿<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:primitives="clr-namespace:BoilenEditor.Primitives"
             x:Class="BoilenEditor.App"
             StartupUri="MainWindow.xaml">
    <Application.Resources>

        <primitives:FileExtensionToImageConverter x:Key="FileExtensionToImage" />

        <primitives:TitleCaseToLabelConverter x:Key="TitleCaseToLabel" />

        <primitives:MatchedValueConverter x:Key="BooleanToVisibility"
                                          DefaultResult="Collapsed">
            <primitives:MatchPair Value="True"
                                  Result="Visible" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="BooleanToHiddenVisibility"
                                          DefaultResult="Hidden">
            <primitives:MatchPair Value="True"
                                  Result="Visible" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="BooleanToFontStyle"
                                          DefaultResult="Normal">
            <primitives:MatchPair Value="False"
                                  Result="Italic" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="CountToVisibility"
                                          DefaultResult="Visible">
            <primitives:MatchPair Value="0"
                                  Result="Collapsed" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="SingleToVisibility"
                                          DefaultResult="Collapsed">
            <primitives:MatchPair Value="0"
                                  Result="Visible" />
            <primitives:MatchPair Value="1"
                                  Result="Visible" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="MultipleToVisibility"
                                          DefaultResult="Visible">
            <primitives:MatchPair Value="0"
                                  Result="Collapsed" />
            <primitives:MatchPair Value="1"
                                  Result="Collapsed" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="StringToVisibility"
                                          DefaultResult="Visible">
            <primitives:MatchPair Value="{x:Null}"
                                  Result="Hidden" />
            <primitives:MatchPair Value="{x:Static sys:String.Empty}"
                                  Result="Hidden" />
        </primitives:MatchedValueConverter>

        <primitives:MatchedValueConverter x:Key="NoStringToVisibility"
                                          DefaultResult="Collapsed">
            <primitives:MatchPair Value="{x:Null}"
                                  Result="Visible" />
            <primitives:MatchPair Value="{x:Static sys:String.Empty}"
                                  Result="Visible" />
        </primitives:MatchedValueConverter>


        <sys:Double x:Key="MinimumWidth">160</sys:Double>

        <SolidColorBrush x:Key="SecondaryInfoBrush"
                         Color="#FF555555" />

        <GroupStyle x:Key="FileGroupStyle">
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name, Mode=OneWay}"
                               Margin="0,0,10,0"
                               FontWeight="Bold" />
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
            <GroupStyle.Panel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </GroupStyle.Panel>
        </GroupStyle>


        <Style TargetType="Window">
            <Setter Property="Icon"
                    Value="Images\boilen.ico" />
        </Style>

        <Style x:Key="DialogButton"
               TargetType="Button">
            <Setter Property="Margin"
                    Value="5" />
            <Setter Property="Padding"
                    Value="10,5" />
        </Style>

        <Style x:Key="CodeTextBox"
               TargetType="Control">
            <Setter Property="FontFamily"
                    Value="Consolas" />
            <Setter Property="FontSize"
                    Value="{DynamicResource FontSize}" />
            <Setter Property="Padding"
                    Value="5,0" />
        </Style>

        <Style x:Key="FilesListBox"
               TargetType="ListBox">
            <Style.Resources>
                <Style TargetType="ListBoxItem">
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
                                         Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
                    </Style.Resources>
                </Style>
            </Style.Resources>

            <Setter Property="BorderThickness"
                    Value="0" />
            <Setter Property="IsTabStop"
                    Value="False" />
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate DataType="data:FileData">
                        <StackPanel Orientation="Horizontal" ToolTip="{Binding FilePath}">
                            <Image Source="{Binding Extension, Converter={StaticResource FileExtensionToImage}}"
                                   Margin="5"
                                   SnapsToDevicePixels="True" />
                            <TextBlock Text="{Binding DisplayName}"
                                       Margin="0,5,5,5"
                                       VerticalAlignment="Center"
                                       FontStyle="{Binding IsBoilenFile, Converter={StaticResource BooleanToFontStyle}}" />
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Application.Resources>
</Application>
